public class AverageAverage {
   public double average(int[] numList) {
		int len=numList.length;
		if(len==1)return numList[0];
		if(len==2)return (numList[0]+numList[1])*(3.0/2.0)/3;
		else{
			double answer1=0;
			for(int i=1;i<len;i++)
				answer1+=average2(numList,i);
			double sum=0;
			for(int i=0;i<len;i++)
				sum=sum+numList[i];
			answer1+=sum/len;
			return answer1/(Math.pow(2,len)-1);
		}
   }
   public int factorial(int a){
	   if(a==1 || a==0)return 1;
	   else return a*factorial(a-1);
   }
   public double average2(int[]source,int required){
	   double answer=0;
	   double current=0;
	   int[] positions=new int[required];
	   int num=0;
	   if(required==1){
		   double sum=0;
		   for(int i=0;i<source.length;i++)
			   sum=sum+source[i];
		   return sum;
	   }
	   for(int i=0;i<required;i++)
		   positions[i]=i;
	   while(positions[0]<source.length-required+1){
		   for(int i=0;i<required;i++)
			   current+=source[positions[i]];
		   current=current/required;
		   answer=answer+current;
		   positions[required-1]++;
		   for(int i=required-1;i>0;i--){
			   if(positions[i]>source.length-required+i){
				   positions[i-1]++;
				   for(int j=i;j<required;j++)
					   positions[j]=positions[i-1]+(j-i+1);
			   }
		   }
		   current=0;
		   num++;
	   }
	   num--;
	   return answer;
   }


// BEGIN CUT HERE
   public static void main(String[] args) {
		if (args.length == 0) {
			AverageAverageHarness.run_test(-1);
		} else {
			for (int i=0; i<args.length; ++i)
				AverageAverageHarness.run_test(Integer.valueOf(args[i]));
		}
	}
// END CUT HERE
}

// BEGIN CUT HERE
class AverageAverageHarness {
	public static void run_test(int casenum) {
		if (casenum != -1) {
			if (runTestCase(casenum) == -1)
				System.err.println("Illegal input! Test case " + casenum + " does not exist.");
			return;
		}
		
		int correct = 0, total = 0;
		for (int i=0;; ++i) {
			int x = runTestCase(i);
			if (x == -1) {
				if (i >= 100) break;
				continue;
			}
			correct += x;
			++total;
		}
		
		if (total == 0) {
			System.err.println("No test cases run.");
		} else if (correct < total) {
			System.err.println("Some cases FAILED (passed " + correct + " of " + total + ").");
		} else {
			System.err.println("All " + total + " tests passed!");
		}
	}
	
	static final double MAX_DOUBLE_ERROR = 1E-9;
	static boolean compareOutput(double expected, double result){ if(Double.isNaN(expected)){ return Double.isNaN(result); }else if(Double.isInfinite(expected)){ if(expected > 0){ return result > 0 && Double.isInfinite(result); }else{ return result < 0 && Double.isInfinite(result); } }else if(Double.isNaN(result) || Double.isInfinite(result)){ return false; }else if(Math.abs(result - expected) < MAX_DOUBLE_ERROR){ return true; }else{ double min = Math.min(expected * (1.0 - MAX_DOUBLE_ERROR), expected * (1.0 + MAX_DOUBLE_ERROR)); double max = Math.max(expected * (1.0 - MAX_DOUBLE_ERROR), expected * (1.0 + MAX_DOUBLE_ERROR)); return result > min && result < max; } }
	static double relativeError(double expected, double result) { if (Double.isNaN(expected) || Double.isInfinite(expected) || Double.isNaN(result) || Double.isInfinite(result) || expected == 0) return 0; return Math.abs(result-expected) / Math.abs(expected); }
	
	static String formatResult(double res) {
		return String.format("%.10g", res);
	}
	
	static int verifyCase(int casenum, double expected, double received) { 
		System.err.print("Example " + casenum + "... ");
		if (compareOutput(expected, received)) {
			System.err.print("PASSED");
			double rerr = relativeError(expected, received);
			if (rerr > 0) System.err.printf(" (relative error %g)", rerr);
			System.err.println();
			return 1;
		} else {
			System.err.println("FAILED");
			System.err.println("    Expected: " + formatResult(expected)); 
			System.err.println("    Received: " + formatResult(received)); 
			return 0;
		}
	}

	static int runTestCase(int casenum) {
		switch(casenum) {
		case 0: {
			int[] numList             = {1,2,3};
			double expected__         = 2.0;

			return verifyCase(casenum, expected__, new AverageAverage().average(numList));
		}
		case 1: {
			int[] numList             = {42};
			double expected__         = 42.0;

			return verifyCase(casenum, expected__, new AverageAverage().average(numList));
		}
		case 2: {
			int[] numList             = {3,1,4,15,9};
			double expected__         = 6.4;

			return verifyCase(casenum, expected__, new AverageAverage().average(numList));
		}

		// custom cases

/*      case 3: {
			int[] numList             = ;
			double expected__         = ;

			return verifyCase(casenum, expected__, new AverageAverage().average(numList));
		}*/
/*      case 4: {
			int[] numList             = ;
			double expected__         = ;

			return verifyCase(casenum, expected__, new AverageAverage().average(numList));
		}*/
/*      case 5: {
			int[] numList             = ;
			double expected__         = ;

			return verifyCase(casenum, expected__, new AverageAverage().average(numList));
		}*/
		default:
			return -1;
		}
	}
}

// END CUT HERE
